import axios from 'axios';
import {API_NEW_VERSION, API_VERSION, ALL_SERVICE_API} from '../api';

var qs = require('qs');
// 路径
const DICTENTITY = API_VERSION + 'fdict_entitys/fdict_entitys';

const PARTNERS = API_NEW_VERSION + 'partners';
const PARTNERSNEW = ALL_SERVICE_API + '/' + 'partners';

const PARTNERS_MODIFY_STATUSS = API_NEW_VERSION + 'partners_modify_statuss';
const PARTNERS_MODIFY_STATUSS_NEW = ALL_SERVICE_API + '/' + 'partners_modify_status';

const PARTNER = API_NEW_VERSION + 'partners/';

const PARTNER_DELETE = API_NEW_VERSION + 'partner_delete/';
const PARTNER_DELETE_NEW = ALL_SERVICE_API + '/' + 'partners/';

const PARTNERS_UPDATE_PASSWORD = API_NEW_VERSION + 'partners_update_password';
const PARTNERS_UPDATE_PASSWORD_NEW = ALL_SERVICE_API + '/' + 'partners_reset_password';

// 获取列表
export const searchPartners = params => {
  return axios.get(PARTNERS, {params: params});
};

export const searchPartnersNew = params => {
  return axios.get(PARTNERSNEW + '/vo', {params: params});
};

// 根据ID更改密码

export const updatePassWord = (id, password) => {
  return axios.post(PARTNERS_UPDATE_PASSWORD, qs.stringify({id: id, password: password}));
};

// 根据ID更改密码(新框架)

export const updatePassWordNew = (id, password) => {
  return axios.put(PARTNERS_UPDATE_PASSWORD_NEW, qs.stringify({id: id, password: password}));
};

// (批量)启用/停用
export const batchStart = (id, status) => {
  return axios.post(PARTNERS_MODIFY_STATUSS, qs.stringify({id: id.join(','), status: status}));
};

// (批量)启用/停用（新框架）
export const batchStartNew = (id, status) => {
  return axios.post(PARTNERS_MODIFY_STATUSS_NEW, qs.stringify({id: id.join(','), status: status}));
};

// 删除合伙人
export const batchDel = id => {
  return axios.delete(PARTNER_DELETE + id);
};

// 删除合伙人（新框架）
export const batchDelNew = id => {
  return axios.delete(PARTNER_DELETE_NEW + id);
};

// 根据ID获取合伙人信息
export const getPartner = id => {
  return axios.get(PARTNER + id);
};

// 根据ID获取合伙人信息（新框架）
export const getPartnerNew = id => {
  return axios.get(PARTNERSNEW + '/' + id);
};

// 保存合伙人信息
export const savePartner = (params) => {
  return axios.post(PARTNERS, params);
};

// 新增合伙人信息(新框架)
export const savePartnerNew = (params) => {
  return axios.post(PARTNERSNEW, params);
};

// 修改合伙人信息(新框架)
export const modifyPartnerNew = (params) => {
  return axios.put(PARTNERSNEW, params);
};

// 查询字典项
export const searchDictEntitys = id => {
  return axios.get(DICTENTITY, {params: {dictCode: id}});
};
